/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tubosmonterrey.cotizador.tb;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author rsoberanis
 */
@Entity
@Table(name = "tbcotizacion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tbcotizacion.findAll", query = "SELECT t FROM Tbcotizacion t"),
    @NamedQuery(name = "Tbcotizacion.findById", query = "SELECT t FROM Tbcotizacion t WHERE t.id = :id"),
    @NamedQuery(name = "Tbcotizacion.findByTotal", query = "SELECT t FROM Tbcotizacion t WHERE t.total = :total"),
    @NamedQuery(name = "Tbcotizacion.findByFecha", query = "SELECT t FROM Tbcotizacion t WHERE t.fecha = :fecha")})
public class Tbcotizacion implements Serializable {
    @Column(name =     "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "total")
    private Double total;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tbcotizacion")
    private Collection<TbcotizacionPos> tbcotizacionPosCollection;
    @JoinColumn(name = "iva", referencedColumnName = "id")
    @ManyToOne
    private Tbiva iva;
    @JoinColumn(name = "usuario", referencedColumnName = "id")
    @ManyToOne
    private Tbusuarios usuario;
    @JoinColumn(name = "cliente", referencedColumnName = "id")
    @ManyToOne
    private Tbclientes cliente;

    public Tbcotizacion() {
    }

    public Tbcotizacion(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    @XmlTransient
    public Collection<TbcotizacionPos> getTbcotizacionPosCollection() {
        return tbcotizacionPosCollection;
    }

    public void setTbcotizacionPosCollection(Collection<TbcotizacionPos> tbcotizacionPosCollection) {
        this.tbcotizacionPosCollection = tbcotizacionPosCollection;
    }

    public Tbiva getIva() {
        return iva;
    }

    public void setIva(Tbiva iva) {
        this.iva = iva;
    }

    public Tbusuarios getUsuario() {
        return usuario;
    }

    public void setUsuario(Tbusuarios usuario) {
        this.usuario = usuario;
    }

    public Tbclientes getCliente() {
        return cliente;
    }

    public void setCliente(Tbclientes cliente) {
        this.cliente = cliente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tbcotizacion)) {
            return false;
        }
        Tbcotizacion other = (Tbcotizacion) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.tubosmonterrey.cotizador.tb.Tbcotizacion[ id=" + id + " ]";
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }
    
}
